package leetcode.method.pointer;

public class Program392StringSubsequence {
    public Program392StringSubsequence() {
    }

    public boolean isSubsequence(String s, String t) {
        if (s.length() < 1) return true;
        if (t.length() < 1) return false;
        char[] sCharArray = s.toCharArray();
        char[] tCharArray = t.toCharArray();
        int i = 0, j = 0;
        while (j < tCharArray.length && i < sCharArray.length) {
            if (tCharArray[j] == sCharArray[i]) {
                i++;
            }
            j++;
        }

        return i == sCharArray.length;
    }

    public static void main(String[] args) {
        Program392StringSubsequence obj = new Program392StringSubsequence();
        System.out.println(obj.isSubsequence("abc","ahbgdc"));
        System.out.println(obj.isSubsequence("axc","ahbgdc"));
    }
}
